#pragma once
#include "faiss_index.h"
#include <map>
#include "filter_index.h"
class IndexFactory{
public:
    static IndexFactory& getGlobalIndexFactory();
    enum class IndexType {
        FLAT,
        HNSW,
        FILTER,
        UNKNOWN = -1 
    };

    enum class MetricType {
        L2,
        IP
    };
    void init(IndexType type,int dim=1,int num_data=0,MetricType metric=MetricType::L2);
    void* getIndex(IndexType type)const;
    //快照
    void saveIndex(const std::string& folderPath,ScalarStorage& scalarStorage);
    void loadIndex(const std::string& folderPath,ScalarStorage& scalarStorage);
    //禁止拷贝构造和赋值构造
    IndexFactory(const IndexFactory&)=delete;
    IndexFactory& operator=(const IndexFactory&)=delete;
private:
    IndexFactory()=default;
    ~IndexFactory()=default;
    std::map<IndexType,void*> index_map;
};